<template>
    <el-container>
        <el-header>
            <div class="left-panel">
	            <!--导出-->
	            <sc-export-button :auth="'finance.recordExport'" :apiObj="apiObj" :search="search"></sc-export-button>
                <div class="finish">
                    <div class="finishNum">{{$t('finance.allrevenue')}}:<div class="text">{{total_stock.collect}}</div></div>
                    <div class="finishNum">{{$t('finance.allexpendi')}}:<div class="text">{{total_stock.pay}}</div></div>
                </div>
            </div>
            <div class="right-panel">
                <div class="right-panel-search">
                    <el-date-picker v-model="search.business_date" :value-format="'YYYY-MM-DD'" type="daterange" range-separator="To" :start-placeholder="$t('all.startdate')" :end-placeholder="$t('all.enddate')" style="width: 230px" />
                    <el-select v-model="search.customer_id" filterable clearable :placeholder="$t('all.select')">
                        <el-option v-for="item in clientList" :key="item.id" :label="item.customer_name" :value="item.id"/>
                    </el-select>
                    <el-select v-model="search.supplier_id" :placeholder="$t('procure.apply.apply')" filterable clearable>
                        <el-option v-for="item in applyList" :key="item.apply_id" :label="item.apply_name" :value="item.apply_id"></el-option>
                    </el-select>
                    <!-- <el-input v-model="search.open_bank" placeholder="请输入开户行" clearable @keyup.enter="upsearch"></el-input> -->
                    <el-button type="primary" icon="el-icon-search" @click="upsearch"></el-button>
                    <el-button type="primary" icon="el-icon-refresh" @click="refresh"></el-button>
                </div>
            </div>
        </el-header>
        <el-main class="nopadding">
            <scTable ref="table" row-key="id" :apiObj="apiObj" @selection-change="selectionChange" stripe remoteSort remoteFilter border @setExtend="setExtend">
                <el-table-column type="selection" width="50" reserve-selection align="center"></el-table-column>
                <el-table-column type="index" :label="$t('all.sort')" fixed align="center" width="60"></el-table-column>
                <el-table-column :label="$t('finance.orderdate')" prop="collect_pay_code" align="center"></el-table-column>
                <el-table-column :label="$t('sale.sale.date')" prop="business_date" align="center"></el-table-column>
                <el-table-column :label="$t('sale.client.name')" prop="customer.customer_name" align="center"></el-table-column>
                <el-table-column :label="$t('all.status')" prop="is_cancel" align="center">
                    <template #default="scope">
                        <!-- <el-tag :type="scope.row.is_cancel == 1 ? 'warning' :  'success'">
                            {{scope.row.is_cancel == 1 ? ' 已作废' : '正常'}}
                        </el-tag> -->
                        <el-tag type="warning" v-if="scope.row.is_cancel == 1">{{$t('all.invalid')}}</el-tag><!-- 已完成 -->
                        <el-tag type="success" v-else>{{$t('production.normal')}}</el-tag><!-- 已作废 -->
                    </template>
                </el-table-column>
                <el-table-column :label="$t('procure.apply.name')" prop="supplier.apply_name" align="center"></el-table-column>
                <!-- <el-table-column :label="$t('sale.client.contacts')" prop="customer.contacts" align="center"></el-table-column>
                <el-table-column :label="$t('sale.client.mobile')" prop="customer.mobile" align="center"></el-table-column> -->
                <el-table-column :label="$t('finance.account')" prop="settlement.account" align="center"></el-table-column>
                <el-table-column :label="$t('finance.income')" prop="collect" align="center"></el-table-column>
                <el-table-column :label="$t('finance.expenditure')" prop="pay" align="center"></el-table-column>
            </scTable>
        </el-main>
    </el-container>
</template>

<script>

export default {
	name: '客户列表',
	data() {
		return {
			apiObj: this.$API.finance.recordlist,
			selection: [],
			search: {
				customer_id: null,
                supplier_id:null,
			},
            clientList: [],
            applyList: [],
            total_stock: {},
		}
	},
    mounted () {
        this.getClient();
        this.getApply()
    },
	methods: {
        setExtend(data){
            this.total_stock = data
        },
		//搜索
		upsearch() {
			this.$refs.table.upData(this.search)
		},
        refresh(){
            for (const key in this.search) {
                this.search[key] = null;
            }
            this.$refs.table.upData(this.search)
        },
		// 客户
        async getClient(){
            var res = await this.$API.client.client.all.get();
            this.clientList = res.data;
        },
        // 供应商
        async getApply(){
            var res = await this.$API.apply.apply.all.get();
            this.applyList = res.data;
        },
	}
}
</script>

<style></style>
